home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / shadow-i.002 / shadow-i / shadow-ina-box-1.1 / modify.c < prev    next >
C/C++ Source or Header  |  1996-06-13  |  2KB  |  96 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5.  
  6. void main()
  7. {
  8.     FILE *f1, *f2;
  9.     char string[100];
  10.     int ftp=0, xlock=0;
  11.  
  12. /*
  13.   Looking if is  root  who is compiling this package ...
  14. */
  15.  
  16.     if( getuid() != 0 )
  17.     { 
  18.     printf( "\n Only ROOT can install shadow package. Sorry !\n\n" );
  19.     system( "touch Fail" );
  20.         exit( 1 );           
  21.     } 
  22.  
  23. /* 
  24.   Opening the file /etc/inetd.conf in order to modify the line containing 
  25.   wu.ftpd into in.ftpd, the new ftp daemon with shadow support.
  26. */   
  27.  
  28.     f1 = fopen( "/etc/inetd.conf", "r" );
  29.     f2 = fopen( "/tmp/inetd.conf", "w" );
  30.     while( !feof( f1 ) )
  31.     {
  32.     fgets( string, 90, f1 );
  33.     if ( !strncmp( string, "ftp", 3 ) )
  34.     {
  35.         string[ strlen( string ) - 8 ] = '\0';
  36.         strcat( string, "ftpd\n" );
  37.         ftp = 1;
  38.     }
  39.     if ( !strncmp( string, "pop3", 4 ) )
  40.     {
  41.         string[ strlen( string ) - 9 ] = '\0';
  42.         strcat( string, "popper\n" );
  43.         ftp = 1;
  44.     }
  45.     if ( !feof( f1 ) )
  46.         fputs( string, f2 );
  47.     }
  48.     fclose( f1 );
  49.     fclose( f2 );
  50.     if( ftp )
  51.     {
  52.     system( "mv -f /etc/inetd.conf /etc/inetd.conf.orig" );
  53.     system( "mv -f /tmp/inetd.conf /etc/inetd.conf" );
  54.     system( "chmod go+r /etc/inetd.conf" );
  55.     }
  56.     else
  57.     {
  58.     printf("\nCan't find /etc/inetd.conf, wu.ftpd or in.pop3 command line in it!\n\n");
  59.     }     
  60.  
  61. /* 
  62.    Opening the file /usr/X11R6/lib/X11/config/linux.cf in order to set the
  63.    variable HasShadowPassword to YES for a correct compiling of xlockmore.
  64.    File path is set for X11R6 release. If you use a previous version modify
  65.    it !
  66. */
  67.  
  68.     f1 = fopen( "/usr/X11R6/lib/X11/config/linux.cf", "r" );
  69.     f2 = fopen( "/tmp/linux.cf", "w" );
  70.     while( !feof( f1 ) )
  71.     {
  72.     fgets( string, 90, f1 );
  73.     if ( !strncmp( string, "#define HasShadowPasswd", 23 ) )
  74.     {
  75.         string[ strlen( string ) - 3 ] = '\0';
  76.         strcat( string, "YES\n" );
  77.         xlock = 1;
  78.     }
  79.     if ( !feof( f1 ) )
  80.         fputs( string, f2 );
  81.     }
  82.     fclose( f1 );   
  83.     fclose( f2 );
  84.     if( xlock )
  85.     {
  86.     system( "mv -f /usr/X11R6/lib/X11/config/linux.cf /usr/X11R6/lib/X11/config/linux.cf.orig" );
  87.     system( "mv -f /tmp/linux.cf /usr/X11R6/lib/X11/config/linux.cf" );
  88.     system( "chmod go+r /usr/X11R6/lib/X11/config/linux.cf" );
  89.     }
  90.     else
  91.     {
  92.     printf( "\nCan't find /usr/X11R6/lib/X11/config/linux.cf or HasShadowPasswd variable in it!\n\n" );
  93.     }   
  94.  
  95. }
  96.